package com.lyh.hkcloud.constants;


import com.lyh.hkcloud.util.base.StringUtils;

public class UrlConstants {
    public static String BASE_URL = null;
    public static String BUS_ROOT = null;
    public static String PRINT_ROOT = null;
    public static String WMS_ROOT = null;

    public static String key = null;
    public static Long version = 0L;

    public static String convertFullUrl(String url) {
        if (StringUtils.isEmpty(url)) {
            return "";
        }
        if (!url.startsWith("http://") && !url.startsWith("https://")) {
            url = UrlConstants.BASE_URL + "/doFile/" + url;
        }
        return url;
    }

    public static UrlItem[] urlItems() {
        return new UrlItem[]{
                new UrlItem("内网生产", "http://192.168.11.133", "http://192.168.11.133/eip-mapp-sapwms-server", "http://192.168.11.133/eip-mapp-print-server", "http://192.168.11.133/eip-mapp-wms-server"),
                new UrlItem("内网测试", "http://192.168.11.133", "http://192.168.11.133/sapwms-api", "http://192.168.11.133/eip-mapp-printtest-server", "http://192.168.11.133/eip-mapp-wmstest-server"),
                new UrlItem("外网测试", "http://10.123.236.106", "http://10.123.236.106/eip-mapp-sapwms-server", "http://10.123.236.106/eip-mapp-print-server", "http://10.123.236.106/eip-mapp-wms-server"),
                new UrlItem("外网开发", "http://10.123.236.106", "http://10.123.236.106/eip-mapp-sapwms-server", "http://10.123.236.106/eip-mapp-print-server", "http://10.123.9.105:8511")
        };
    }

    public static class UrlItem implements CharSequence {
        public String name;
        public String baseUrl;
        public String busUrl;
        public String printUrl;
        public String wmsUrl;

        public UrlItem(String name, String baseUrl, String busUrl, String printUrl, String wmsUrl) {
            this.name = name;
            this.baseUrl = baseUrl;
            this.busUrl = busUrl;
            this.printUrl = printUrl;
            this.wmsUrl = wmsUrl;
        }

        @Override
        public int length() {
            if (name != null) {
                return name.length();
            }
            return 0;
        }

        @Override
        public char charAt(int index) {
            if (name != null) {
                return name.charAt(index);
            }
            return 0;
        }

        @Override
        public CharSequence subSequence(int start, int end) {
            return null;
        }

        @Override
        public String toString() {
            return name;
        }
    }
}
